package com.csdj.game.vo;

import com.csdj.game.constant.ResultCodeContant;

import java.util.HashMap;
import java.util.Map;

/**
 * 统一返回给前端的数据格式
 * author:cloud
 * date:2021/3/30 0030
 **/
public class WebResult {
    private int code;
    private String msg;
    private Map<String,Object> result = new HashMap<>();

    public WebResult(){}

    public static WebResult build(int code){
        WebResult result = new WebResult();
        result.setCode(code);
        result.setMsg(ResultCodeContant.errMsgMap.get(code));
        return result;
    }

    public WebResult putData(String key,Object data){
        this.result.put(key,data);
        return this;
    }


    public WebResult(int code, Map<String, Object> result) {
        this.code = code;
        this.result = result;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Map<String, Object> getResult() {
        return result;
    }

    public void setResult(Map<String, Object> result) {
        this.result = result;
    }
}
